// 发起支付
router.post("/api/pay/payment", function(req, res, next) {
    // 前端传的参数
    let params = req.body

    // 开始对接支付宝API
    const formData = new AlipayFormData()
    formData.setMethod("get")
        // 支付时的信息
    formData.addField("bizContent", {
        outTradeNo: params.id, //订单号
        productCode: "FAST_INSTANT_TRADE_PAY",
        totalAmount: params.price, //总价格
        subject: "购票演出", //商品名称
        body: "", //商品描述
    })

    // 支付成功失败跳转的连接
    formData.addField("returnUrl", `http://localhost:8080/#/movie_detail?movie_id=${id}`)
    const reslut = alipaySdk.exec(
        "alipay.trade.page.pay", {}, { formData: formData }
    )

    reslut.then((resp) => {
        res.send({
            data: {
                code: 200,
                success: true,
                msg: "支付中",
                paymentUrl: resp,
            },
        })
    })
})